home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / AMUG Info / Apple / MacsBug 6.2.2 / dcmds / Pascal Samples / Where.p < prev   
Encoding:
Text File  |  1991-11-19  |  1.9 KB  |  74 lines  |  [TEXT/MPS ]

  1. UNIT Where;
  2.  
  3. (* The following MPW commands will build the dcmd and copy it to the
  4.    "Debugger Prefs" file in the System folder. The dcmd's name in
  5.          MacsBug will be the name of the file built by the Linker.
  6.  
  7.         Pascal Where.p
  8.         Link dcmdGlue.a.o Where.p.o {Libraries}Runtime.o -o Where
  9.         BuildDcmd Where 102
  10.                     Echo 'include "Where";'            |            Rez -a -o "{systemFolder}Debugger Prefs"
  11. *)
  12.  
  13. {$R-}
  14.  
  15. INTERFACE
  16.  
  17.         USES MemTypes, dcmd;
  18.         
  19.   { Public declaration for dcmdGlue. Must be in every dcmd. The name cannot be changed. }
  20.         PROCEDURE CommandEntry (paramPtr: dcmdBlockPtr);
  21.  
  22.  
  23. IMPLEMENTATION
  24.  
  25. CONST CR = $0D;
  26.  
  27.  
  28. PROCEDURE CommandEntry (paramPtr: DCmdBlockPtr);
  29. VAR address: LONGINT;
  30.     ch:      CHAR;
  31.                 ok:      BOOLEAN;
  32.                 name:    Str255;
  33. BEGIN
  34.   IF paramPtr^.request = dcmdInit THEN
  35.           BEGIN { The dcmd gets called once when loaded to init itself }
  36.                 END
  37.         ELSE
  38.   IF paramPtr^.request = dcmdDoIt THEN
  39.           BEGIN { Do the command's normal function }
  40.                 IF dcmdPeekAtNextChar = CHR(CR) THEN
  41.                   address := paramPtr^.registerFile^[PCRegister]
  42.                 ELSE
  43.                   BEGIN
  44.                   ch := dcmdGetNextExpression (address, ok);
  45.                         IF NOT ok THEN
  46.                           BEGIN
  47.                                 dcmdDrawLine ('Syntax error');
  48.                                 Exit (CommandEntry);
  49.                                 END;
  50.                         END;
  51.                 IF (address >= $0000A000) AND (address <= $0000ABFF) THEN
  52.                   BEGIN
  53.                         dcmdGetTrapName (address, name);
  54.                         dcmdDrawLine (name);
  55.                         END
  56.                 ELSE
  57.                   BEGIN
  58.                         dcmdGetNameAndOffset (address, name);
  59.                   IF Length (name) > 0
  60.                           THEN dcmdDrawLine (name)
  61.                                 ELSE dcmdDrawLine ('No procedure name found');
  62.                         END;
  63.                 END
  64.         ELSE
  65.   IF paramPtr^.request = dcmdHelp THEN
  66.           BEGIN { Display the command's help information }
  67.                 dcmdDrawLine ('WHERE [addr | trap]');
  68.                 dcmdDrawLine ('   Display information about the address or trap');
  69.                 dcmdDrawLine ('   If no parameter then use PC as the address');
  70.                 END;
  71. END;
  72.  
  73. END.
  74.